<section class="content-header">
  <!-- <h1>新增收件</h1> -->
  <ol class="breadcrumb">
    <li><a ui-sref="dashboard"><i class="fa fa-dashboard"></i>我的面板</a></li>
    <li><a ui-sref="inbox">收件列表</a></li>
    <li class="active" ng-bind="current_bread"></li>
  </ol>
</section>
<section class="content" style="padding-bottom: 100px;">
  <form class="form-horizontal" id="inbox_form">
    <div class="detail-view-header-wrapper">
      <div class="box-footer detail-view-header" ui-scrollpoint ui-scrollpoint-enabled="true" ui-scrollpoint-class="fixed">
        <button type="button" class="btn btn-info" ng-click="save()">保存</button>
        <button type="button" class="btn btn-default" ng-click="cancel()">取消</button>
      </div>
    </div>
    <div class="box box-danger">
      <div class="box-header with-border">
        <h3 class="box-title">基本信息</h3>
        <div class="box-tools">
          <div class="box-tools pull-right">
            <button type="button" class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i>
            </button>
          </div>
        </div>
      </div>
      <div class="box-body">
        <div class="form-group">
          <label class="col-sm-2 control-label">信件单号<span class="required">*</span></label>
          <div class="col-sm-8">
            <input type="text" class="form-control" name="code" ng-model="data.code" data-rule="required; length[~50];">
          </div>
        </div>
        <div class="form-group">
          <label class="col-sm-2 control-label">信件内容</label>
          <div class="col-sm-8">
            <input type="text" class="form-control" name="letter_type" ng-model="data.letter_type" placeholder="信函、邮单、杂志等" data-rule="length[~20];">
          </div>
        </div>
        <div class="form-group">
          <label class="col-sm-2 control-label"><span>寄件人</span><span class="required">*</span></label>
          <div class="col-sm-8">
            <input type="text" class="form-control" name="owner" ng-model="data.owner" data-rule="required; length[~100];">
          </div>
        </div>
        <div class="form-group">
          <label class="col-sm-2 control-label"><span>收件日期</span><span class="required">*</span></label>
          <div class="col-sm-8">
            <input type="text" class="form-control date-input" id="date_at" name="date_at" ng-model="data.date_at" data-rule="required;">
          </div>
        </div>
        <div class="form-group">
          <label class="col-sm-2 control-label">快递公司</label>
          <div class="col-sm-8">
            <input type="text" class="form-control" name="merchant" ng-model="data.merchant" data-rule="length[~20];">
          </div>
        </div>
        <div class="form-group">
          <label class="col-sm-2 control-label">付费方式<span class="required">*</span></label>
          <div class="col-sm-8">
            <select class="form-control select2" name="paymode" ng-model="data.paymode" data-rule="required;">
              <option value="">请选择</option>
              <option value="到付">到付</option>
              <option value="寄付">寄付</option>
            </select>
          </div>
        </div>
        <div class="form-group">
          <label class="col-sm-2 control-label">备注</label>
          <div class="col-sm-8">
            <textarea class="form-control" rows="3" name="description" ng-model="data.description" data-rule="length[~300];"></textarea>
          </div>
        </div>
        <div class="form-group" ng-if="action=='update'">
          <label class="col-sm-2 control-label">关联订单</label>
          <div class="col-sm-2">
            <select class="form-control select2" name="order_source" ng-model="data.order_source" ng-change="typeChange(0)">
              <option value="">请选择订单类别</option>
              <option value="reg_abroad">境外注册</option>
              <option value="reg_internal">境内注册</option>
              <option value="audit">审计</option>
              <option value="trademark">商标</option>
              <option value="patent">专利</option>
              <option value="other">其它</option>
            </select>
          </div>
          <div class="col-sm-2">
            <select
              ng-if="data.order_source!='other'"
              class="form-control select2"
              id="orderSelect0"
              name="order_id0"
              style="width: 100%;"
            >
              <option value="">请选择订单</option>
            </select>
            <input
              ng-if="data.order_source=='other'"
              type="text"
              class="form-control date-input"
              id="orderInput0"
              name="orderInput0"
              ng-model="data.order_name"
            >
          </div>
          <div class="col-sm-2">
            <select class="form-control select2" id="auditSelect0" name="audit_id0" ng-model="data.audit_id" ng-options="member.id as member.name for member in memberList" style="width: 100%;">
              <option value="">请选择审核人员</option>
            </select>
          </div>
          <div class="col-sm-2">
            <input
              placeholder="请输入信件数量"
              type="text"
              class="form-control date-input"
              id="qty0"
              name="qty0"
              ng-model="data.qty"
              data-rule="integer(+);"
              ng-change="qtyChange(0)"
            >
          </div>
        </div>
        <div class="form-group" ng-if="action=='add'" ng-repeat="order in data.orders">
          <label class="col-sm-2 control-label" ng-bind="$index==0 ? '关联订单' : ''">关联订单</label>
          <div class="col-sm-2">
            <select class="form-control select2" name="order_source{{$index}}" ng-model="order.order_source" ng-change="typeChange($index)">
              <option value="">请选择订单类别</option>
              <option value="reg_abroad">境外注册</option>
              <option value="reg_internal">境内注册</option>
              <option value="audit">审计</option>
              <option value="trademark">商标</option>
              <option value="patent">专利</option>
              <option value="other">其它</option>
            </select>
          </div>
          <div class="col-sm-2">
            <select
              ng-if="order.order_source!='other'"
              class="form-control select2"
              id="orderSelect{{$index}}"
              name="order_id{{$index}}"
              style="width: 100%;"
            >
              <option value="">请选择订单</option>
            </select>
            <input
              ng-if="order.order_source=='other'"
              type="text"
              class="form-control date-input"
              id="orderInput{{$index}}"
              name="orderInput{{$index}}"
              ng-model="order.order_name"
            >
          </div>
          <div class="col-sm-2">
            <select class="form-control select2" id="auditSelect{{$index}}" name="audit_id{{$index}}" ng-view="audit_name" ng-model="order.audit_id"  style="width: 100%;">
              <option value="">请选择审核人员</option>
              <option ng-repeat="member in memberList" value="{{member.id}}">{{member.name}}</option>
            </select>
          </div>
          <div class="col-sm-2">
              <select 
                class="form-control" 
                id="letter_kind{{$index}}" 
                name="letter_kind{{$index}}" 
                ng-model="order.letter_kind" 
                data-rule="required;"
                ng-change="letterTypeChange($index)"
              >
                <option value="">信件类别</option>
                <option ng-repeat="option in letterType" value="{{option.name}}">{{option.name}}</option>
              </select>
          </div>
          <div class="col-sm-2">
            <input
              placeholder="请输入信件数量"
              type="text"
              class="form-control date-input"
              id="qty{{$index}}"
              name="qty{{$index}}"
              ng-model="order.qty"
              data-rule="integer(+);"
              ng-change="qtyChange($index)"
            >
          </div>
          <div class="col-sm-1">
            <a href="javascript:;" style="display: inline-block; line-height: 30px;" ng-if="$index>0" ng-click="onDel($index, order)">删除</a>
          </div>
        </div>
        <div class="form-group" ng-if="action=='add'">
          <label class="col-sm-2 control-label"></label>
          <div class="col-sm-8">
            <a href="javascript:;" id="btnUpload" style="display: inline-block; line-height: 30px;" ng-click="onAdd()">增加</a>
          </div>
        </div>
      </div>
    </div>
  </form>
</section>
